/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package stackCalc.command;

import java.io.IOException;
import java.util.List;
import stackCalc.Stack;

/**
 *
 * @author signal
 */
public class DEFINECommand extends Command {
	
	@Override
	public void execute(List<Object> args) throws BadArgumentsException
	{
		try {
			((Stack)args.get(0)).getVariables().put((String)args.get(1), (String)args.get(2));
		} catch(ClassCastException cce){
			throw new BadArgumentsException("Cannot identify arguments for this command. Please read docs.\n");
		} catch(IndexOutOfBoundsException ioobe) {
			try {
				out.write("Not enought arguments for this function.\n".getBytes());
			} catch(IOException ioe) {
				System.out.println("Error with writing to output stream.");
			}
		}
	}
	
}
